package com.widevision.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import net.widevision.android.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.widevision.ListActivity.UserProfile;
import com.widevision.utility.ImageLoader;

public class InfoAdapter extends BaseAdapter{
	
	
	private static ArrayList<HashMap<String, String>> data;
    public Activity activity;
    public LayoutInflater inflater;
    ImageLoader imageLoader;
 
    public InfoAdapter(Activity a, ArrayList<HashMap<String, String>> d)
    {
    	 activity = a;
         data=d;
         inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         imageLoader=new ImageLoader(activity.getApplicationContext());
    }
 
    
    public int getCount()
    {
    	 
      	 return data.size();
     }
   
      
      public Object getItem(int position) 
      {
      	 return position;
      }
   
    
      public long getItemId(int position)
      {
      	return position;
      }
      
 
      public static class ViewHolder
      {
        TextView type,value;
       
      }
 
 
    public View getView(int position, View convertView, ViewGroup parent) 
    {
    	final ViewHolder holder = new ViewHolder();
        if(convertView==null)
        
        	convertView = inflater.inflate(R.layout.infoitemlist, null);
            holder.type = (TextView) convertView.findViewById(R.id.type);
            holder.value = (TextView) convertView.findViewById(R.id.value);
            convertView.setTag(holder);
            
            HashMap<String, String> infomap = new HashMap<String, String>();
            
            infomap = data.get(position);
            
            //SETTING ALL ITEM VALUES
       
	        holder.type.setText(infomap.get(UserProfile.LOCATION));
	        holder.value.setText(infomap.get(UserProfile.INFO_NAME));
	        
	        convertView.setTag(holder);
            return convertView;
    }
 
}

